<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="${pageContext.request.contextPath}/include/pageTitleBread.jsp"/>
<div id="page-content">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading">
                <h3 class="panel-title">${pageInfo.innerTitle}</h3>
            </div>
            <form id="wxConfigForm" class="panel-body form-horizontal form-padding">
                <div class="form-group">
                    <label class="col-sm-3 control-label">微信开发者Id(AppId)：</label>
                    <div class="col-sm-5">
                        <input id="flAppId" name="flAppId" class="form-control" type="text">
                        <small class="help-block">请输入XXXX</small>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">微信开发者密码(AppSecret)：</label>
                    <div class="col-sm-5">
                        <input id="flAppSecret" name="flAppSecret" class="form-control" type="text">
                        <small class="help-block">请输入XXXX</small>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">令牌(Token)：</label>
                    <div class="col-sm-5">
                        <input id="flToken" name="flToken" class="form-control" type="text">
                        <small class="help-block">请输入XXXX</small>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">消息加解密密钥：</label>
                    <div class="col-sm-5">
                        <input id="flEncodingAesKey" name="flEncodingAesKey" class="form-control" type="text">
                        <small class="help-block">请输入XXXX</small>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">服务器地址(URL)：</label>
                    <div class="col-sm-5">
                        <input id="flVerifyUrl" name="flVerifyUrl" class="form-control" type="text">
                        <small class="help-block">请输入XXXX</small>
                    </div>
                </div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-sm-9 col-sm-offset-3">
                            <button class="btn btn-warning" type="reset">重置</button>
                            <button class="btn btn-mint" type="submit">保存</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>

    function save() {
        var data = common_ajax.ajaxFunc("/wxConfig/saveOrUpdate", $('#wxConfigForm').serialize(), "json", null);
        if (data.code === 0) {
            pointLion.alertMsg("保存成功!", "success", "small", function () {
                doPjax(ctx + '/wxConfig');//跳转到列表页
            });
        } else {
            pointLion.alertMsg("操作失败!", "danger", "small", function () {
                doPjax(ctx + '/wxConfig');//跳转到列表页
            });
        }
    }

    $(document).ready(function () {
        $('#wxConfigForm').bootstrapValidator({
            excluded: [":hidden"],//关键配置，表示只对于隐藏域不进行验证，其他的表单元素都要验证
            fields: {
                "fl_code": {
                    validators: {
                        notEmpty: {
                            message: '*XXXX不能为空!'
                        },
                        stringLength: {
                            min: 2,
                            message: '*XXXX必须大于两位'
                        }
                    }
                },
                "fl_name": {
                    validators: {
                        notEmpty: {
                            message: '*XXXX不能为空'
                        },
                        stringLength: {
                            min: 2,
                            message: '*XXXX必须大于两位'
                        }
                    }
                }
            }
        }).on("success.form.bv", function (e) {
            save();
            return false;//阻止表单跳转
        });
    });
</script>
